import request from "@/util/request"
import { API_SITE, API_PREFIX } from "./_prefix"
const CUSTOMER_TYPE = "/api/v1/user"

/**
 * 根据用户id获取客户类型
 */
export const getCustomerTypeByUserId = (userid) => {
    return request(`${API_SITE}${CUSTOMER_TYPE}/${userid}/customertype`);
};

/**
 * 新建客户分类
 */
export const createCustomerType = (userid,{name, description}) => {
    console.log(name);
    console.log(description);
    return request(`${API_SITE}${CUSTOMER_TYPE}/${userid}/customertype`,{
        method: "POST",
        body: {
            name: name,
            description: description,
            type: 1
        }
    })
}
/** 
 * 编辑客户分类信息
*/
export const updateCustomerType = (userid,typeId,{name,description}) => {
    return request(`${API_SITE}${API_PREFIX}/${userid}/customertype/${typeId}`,{
        method: "POST",
        body: {
            name: name,
            description: description,
        }
    })
}

/**
 * 删除客户分类信息
 */
export const deleteCustomerTypeById = (userid,typeId) => {
    return request(`${API_SITE}${API_PREFIX}/${userid}/customertype/${typeId}/delete`,{
        method: "POST",
    })
}